package com.example.opengldemo._112_;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;

public class Constant {
    public static float[][] yArray;
    public static final float LAND_HIGH_ADJUST=-2f;
    public static final float LAND_HIGHEST=20f;
    public static float[][] loadLandforms(Resources resources, int index){
        Bitmap bt= BitmapFactory.decodeResource(resources, index);
        int colsPlusOne=bt.getWidth();
        int rowsPlusOne=bt.getHeight();
        float[][] result=new float[rowsPlusOne][colsPlusOne];
        for (int w = 0 ; w < colsPlusOne ; w++){
            for(int h = 0 ; h < rowsPlusOne ; h++){
                int color = bt.getPixel(h , w) ;
                int red = Color.red(color);
                int green = Color.green(color);
                int blue = Color.blue(color);
                int ap = (red+green+blue)/3 ;
                result[h][w] = ap*LAND_HIGHEST/255+LAND_HIGH_ADJUST;
            }
        }
        return result ;
    }
}
